/**
 * Handle changed data.
 *
 * @param {Object} [oldValue] old value
 * @param {Object} [newValue] new value
 * @param {JSEvent} [event] the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"C98F2084-EB0C-45E1-9A47-BFB9BCDC6B3A"}
 */
function onDataChange_debe(oldValue, newValue, event) {
	if (importe_carga_debe < 0)
	{
		importe_carga_debe = importe_carga_debe * -1
	}	    
	if (importe_carga_haber < 0)
	{
		importe_carga_haber = importe_carga_haber * -1
	}	
	globals.gtotal_debe = 0
	globals.gtotal_haber = 0
	var $cant = databaseManager.getFoundSetCount(foundset)
	for (var i = 1 ; i <= $cant ; i++)
	{
		var $rcd = foundset.getRecord(i)
		if ($rcd.importe_carga_debe != null)
		{
			globals.gtotal_debe  += $rcd.importe_carga_debe.toFixed(2)*1
		} 
		if ($rcd.importe_carga_haber != null)
		{
			globals.gtotal_haber += $rcd.importe_carga_haber.toFixed(2)*1			
		}		
	}
	return true
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"02838E45-D6F9-4566-AF78-B600DEA4E3D6"}
 */
function onAction_borrar(event) {
	//controller.deleteRecord() 26-04-2011 se cambió porque savedata no restaura dados de baja
	// la baja consiste en opnerle cero al importe y luego, al confirmar, no darle la baja real
	importe_carga_debe = 0
	importe_carga_haber = null
	onDataChange_debe()

}

/**
 * Handle focus element loosing focus.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"BEAAF886-E06D-4148-B6E9-DA93B84886EF"}
 */
function onFocusLost_cuenta(event) {
	elements.cuentas_id.caretPosition = 0
	return true
}
